-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make http://metadata.google.internal configurable #40317
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The TPU client library has a hardcoded dependency on `http://metadata.google.internal`. We happen to need to redirect this URL to a different VM. Since the URL is hardcoded, we're forced to use a fragile code patch against our version of Tensorflow, which isn't ideal, or rely on `/etc/hosts` to forward `metadata.google.internal`, which causes unexpected global side effects to the user's VM. (For example, GCE uses `metadata.google.internal` to distribute SSH keys to GCE VMs, which breaks when we reroute `metadata.google.internal` using `/etc/hosts`.) oauth2client solves this by making `http://metadata.google.internal` configurable via the `GCE_METADATA_IP` environment variable. The final url becomes `'http://' + os.getenv('GCE_METADATA_IP', '169.254.169.254')`: https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L111 Following oauth2client's lead, this PR makes `http://metadata.google.internal` configurable for Tensorflow users via `GCE_METADATA_IP`: ```py _GCE_METADATA_URL_ENV_VARIABLE = 'GCE_METADATA_IP' # ... def _gce_metadata_endpoint(): return 'http://' + os.environ.get( _GCE_METADATA_URL_ENV_VARIABLE, 'metadata.google.internal') ``` `GCE_METADATA_IP` might seem like an awkward name. After all, `metadata.google.internal` is a URL, not an IP address. But it's probably best to match oauth2client's naming convention. That way users won't need to worry about setting two slightly-different variable names to configure both oauth2client and Tensorflow.
Hello! Any word on this? |
mihaimaruseac
previously approved these changes
Jul 29, 2020
google-ml-butler
bot
added
kokoro:force-run
Tests on submitted change
ready to pull
PR ready for merge process
labels
Jul 29, 2020
Can you fix sanity test please?
|
gbaned
removed
awaiting review
Pull request awaiting review
ready to pull
PR ready for merge process
labels
Jul 30, 2020
@shawwn Can you please check @mihaimaruseac's comments and keep us posted ? Thanks! |
@shawwn, Any update on this PR? Please. Thanks! |
Sorry for the delay! I've pushed a new commit. Is the pylint error fixed now? |
mihaimaruseac
approved these changes
Aug 6, 2020
google-ml-butler
bot
added
kokoro:force-run
Tests on submitted change
ready to pull
PR ready for merge process
labels
Aug 6, 2020
gbaned
added
ready to pull
PR ready for merge process
and removed
ready to pull
PR ready for merge process
labels
Aug 6, 2020
gbaned
approved these changes
Aug 7, 2020
google-ml-butler
bot
added
kokoro:force-run
Tests on submitted change
ready to pull
PR ready for merge process
labels
Aug 7, 2020
gbaned
added
ready to pull
PR ready for merge process
and removed
ready to pull
PR ready for merge process
labels
Aug 7, 2020
Achievement unlocked: JAX cited and implemented this PR: https://twitter.com/theshawwn/status/1455464111446315009 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The TPU client library has a hardcoded dependency on
http://metadata.google.internal
. We happen to need to redirect this URL to a different VM. Since the URL is hardcoded, we're forced to use a fragile code patch against our version of Tensorflow, which isn't ideal, or rely on/etc/hosts
to forwardmetadata.google.internal
, which causes unexpected global side effects to the user's VM. (For example, GCE usesmetadata.google.internal
to distribute SSH keys to GCE VMs, which breaks when we reroutemetadata.google.internal
using/etc/hosts
.)oauth2client solves this by making
http://metadata.google.internal
configurable via theGCE_METADATA_IP
environment variable. The final url becomes'http://' + os.getenv('GCE_METADATA_IP', '169.254.169.254')
:https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L111
Following oauth2client's lead, this PR makes
http://metadata.google.internal
configurable for Tensorflow users viaGCE_METADATA_IP
:GCE_METADATA_IP
might seem like an awkward name. After all,metadata.google.internal
is a URL, not an IP address. But it's probably best to match oauth2client's naming convention. That way users won't need to worry about setting two slightly-different variable names to configure both oauth2client and Tensorflow.